package com.lyf.boot.modules.system.controller;

import cn.dev33.satoken.annotation.SaIgnore;
import com.lyf.boot.base.system.entity.ChinaArea;
import com.lyf.boot.core.model.R;
import com.lyf.boot.modules.system.service.IChinaAreaService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * 行政区划
 * @author Luyufan
 * @date 2023/12/6 11:30
 **/
@RestController
@RequestMapping("/chinaArea")
@RequiredArgsConstructor
public class ChinaAreaController {

    private final IChinaAreaService chinaAreaService;

    /**
     * 全量爬取
     * @return
     * @throws IOException
     */
    @GetMapping("crawl")
    @SaIgnore
    public R<Void> crawlChinaArea() throws IOException {
        chinaAreaService.crawlChinaArea();
        return R.ok();
    }

    /**
     * 指定爬取
     * @return
     */
    @GetMapping
    @SaIgnore
    public R<ChinaArea> getChinaArea() {
        return R.ok(chinaAreaService.getById("11"));
    }

}
